import 'dart:convert';

import 'package:base_flutter/base_flutter.dart';

class NetConfig{



  static bool autoUrl =  true;

  static void init(){
    HttpGo.HttpGogetInstance();
    HttpGo.instance.dio?.interceptors.add(TokenInterceptor());
    if(BuildConfig.isDebug){
      // HttpGo.instance.setProxy("192.168.1.3", 8888, true);
      // HttpGo.instance.setProxy("192.168.6.95", 8888, true);
      HttpGo.instance.setProxy("192.168.31.186", 8888, true);
      // HttpGo.instance.setProxy("192.168.3.24", 8888, true);
    }

  }

}

class TokenInterceptor extends Interceptor{

  @override
  void onResponse(Response response, ResponseInterceptorHandler handler) {
    if(response.statusCode==401){

      // Log.d("123123123", 'asdasdads');
      // Go().pushRemoveUntil(LoginPage(loginMsg: '登录失效，请重新登录',));
    }else{
      super.onResponse(response, handler);
    }
  }

  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    options.headers['client-type'] = '3';
    super.onRequest(options, handler);
  }
}